package edu.msg.hrappy.backend.service.beans;

import java.util.Collections;
import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import edu.msg.hrappy.backend.model.Notification;
import edu.msg.hrappy.backend.repository.NotificationRepository;
import edu.msg.hrappy.backend.repository.exception.RepositoryException;
import edu.msg.hrappy.backend.service.NotificationService;
import edu.msg.hrappy.backend.service.exception.ServiceException;
@Stateless
public class NotificationServiceBean  implements NotificationService {
    @EJB
    private NotificationRepository notificationDAO;

    @Override
    public void insert(Notification obj) {

        try {
        	notificationDAO.insert(obj);
        } catch (RepositoryException e) {
            throw new ServiceException("", e);
        }

    }

    @Override
    public void update(Notification obj) {
        try {
        	notificationDAO.update(obj);
        } catch (RepositoryException e) {
            throw new ServiceException("", e);
        }

    }

    @Override
    public void delete(Notification obj) {
        try {
        	notificationDAO.delete(obj);
        } catch (RepositoryException e) {
            throw new ServiceException("", e);
        }

    }

    @Override
    public List<Notification> getAll() {
        List<Notification> all = Collections.emptyList();
        try {
            all = notificationDAO.getAll();
        } catch (RepositoryException e) {
            throw new ServiceException("", e);
        }
        return all;
    }

    @Override
    public Notification getById(Long id) {
    	Notification one;
        try {
            one = notificationDAO.getById(id);
        } catch (RepositoryException e) {
            throw new ServiceException("", e);
        }
        return one;
    }
}
